/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author plebani
 */
@Entity
@Table(name = "actions")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Actions.findAll", query = "SELECT a FROM Actions a"),
    @NamedQuery(name = "Actions.findById", query = "SELECT a FROM Actions a WHERE a.id = :id"),
    @NamedQuery(name = "Actions.findByPersistence", query = "SELECT a FROM Actions a WHERE a.persistence = :persistence"),
    @NamedQuery(name = "Actions.findByPervasiveness", query = "SELECT a FROM Actions a WHERE a.pervasiveness = :pervasiveness"),
    @NamedQuery(name = "Actions.findByMessage", query = "SELECT a FROM Actions a WHERE a.message = :message")})
public class Actions implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private String id;
    @Lob
    @Column(name = "Description")
    private String description;
    @Column(name = "Persistence")
    private String persistence;
    @Column(name = "Pervasiveness")
    private String pervasiveness;
    @Column(name = "Message")
    private String message;
    @OneToMany(mappedBy = "idAction")
    private Collection<Rule> ruleCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "actions")
    private SystemAction systemAction;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "actions")
    private UpdateKb updateKb;

    public Actions() {
    }

    public Actions(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getPersistence() {
        return persistence;
    }

    public void setPersistence(String persistence) {
        this.persistence = persistence;
    }

    public String getPervasiveness() {
        return pervasiveness;
    }

    public void setPervasiveness(String pervasiveness) {
        this.pervasiveness = pervasiveness;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @XmlTransient
    public Collection<Rule> getRuleCollection() {
        return ruleCollection;
    }

    public void setRuleCollection(Collection<Rule> ruleCollection) {
        this.ruleCollection = ruleCollection;
    }

    public SystemAction getSystemAction() {
        return systemAction;
    }

    public void setSystemAction(SystemAction systemAction) {
        this.systemAction = systemAction;
    }

    public UpdateKb getUpdateKb() {
        return updateKb;
    }

    public void setUpdateKb(UpdateKb updateKb) {
        this.updateKb = updateKb;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Actions)) {
            return false;
        }
        Actions other = (Actions) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.Actions[ id=" + id + " ]";
    }
    
}
